import { BasicColumn, useRender } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { userSelect } from '/@/api/backs/system/user';
import { DICT_TYPE } from '/@/utils/dict';
import moment from 'moment';

export const columns: BasicColumn[] = [
  {
    title: '请假人',
    dataIndex: 'userName',
  },
  {
    title: '部门',
    dataIndex: 'deptName',
  },

  {
    title: '请假天数',
    dataIndex: 'days',
  },
  {
    title: '请假开始日期',
    dataIndex: 'startTime',
    customRender: ({ record }) => {
      const time = record.createTime;
      return time ? moment(time).format('YYYY-MM-DD hh:mm') : '-';
    },
  },
  {
    title: '请假结束日期',
    dataIndex: 'endTime',
    customRender: ({ record }) => {
      const time = record.endTime;
      return time ? moment(time).format('YYYY-MM-DD hh:mm') : '-';
    },
  },
  {
    title: '原因',
    dataIndex: 'reason',
  },
  {
    title: '结果',
    dataIndex: 'type',
    customRender: ({ text }) => {
      return useRender.renderDict(text, DICT_TYPE.BPM_PROCESS_INSTANCE_RESULT);
    },
  },
  {
    title: '附件',
    dataIndex: 'leaveUrl',
  },
  {
    title: '工作承接人',
    dataIndex: 'otherUserName',
  },
  {
    title: '工作内容',
    dataIndex: 'workContent',
  },
];

export const searchFormSchema: FormSchema[] = [
  // {
  //   field: 'username',
  //   label: '请假人',
  //   component: 'Input',
  //   colProps: { span: 8 },
  //   componentProps: ({ tableAction }) => {
  //     return {
  //       onPressEnter: () => {
  //         const { reload } = tableAction;
  //         reload();
  //       },
  //     };
  //   },
  // },
];

export const formSchema: FormSchema[] = [
  {
    field: 'projectName',
    label: '项目名称',
    component: 'Input',
    required: true,
    componentProps: {
      placeholder: '请输入项目名称',
    },
  },
  {
    label: '负责人',
    field: 'projectManagerId',
    required: true,
    component: 'ApiSelect',
    componentProps: {
      api: () => userSelect(),
      labelField: 'nickname',
      valueField: 'id',
      getPopupContainer: () => document.body,
    },
  },
  {
    label: '项目开始日期',
    field: 'startDate',
    required: true,
    component: 'DatePicker',
    componentProps: {
      valueFormat: 'X',
      showTime: true,
    },
  },
  {
    label: '项目结束日期',
    field: 'endDate',
    required: true,
    component: 'DatePicker',
    componentProps: {
      valueFormat: 'X',
      showTime: true,
    },
  },
];
